<?php	echo $this->Html->script('ajaxupload.3.5',array("inline"=>false));	?>
<form action="../Eventos/verparticipantes" method="post" class="form-horizontal" role="form">
<input type="hidden" name="data[Evento][id]" value="<?php echo $evento["Evento"]["id"]; ?>">
<div style="width:90%; margin:40px auto 60px auto;">
	<div class="panel panel-default">
		<div class="panel-heading" style="padding:3px 15px;text-align:right;">
			<div style="width:50%;float:left;margin-top:4px;font-size:18px;">Participantes del evento: <?php echo $evento["Evento"]["tema"]; ?></div>
			<button data-toggle="modal" data-target="#editModal" class="btn btn-primary btn-sm" type="button">
				<span class="glyphicon glyphicon-plus-sign"></span> Agregar Evento
			</button>
			<button type="submit" class="btn btn-primary">Guardar Asistencias </button>
		</div>
		<div class="panel-body" style="padding-bottom:10px;">
			<table cellpadding="0" cellspacing="0" border="0" id="example" class="table table-striped table-bordered">
				<thead>
					<tr>
						<th style="text-align: center;">NOMBRE</th>
						<th style="text-align: center;">APELLIDOS</th>
						<th style="text-align: center;">ESTADO</th>
						<th style="text-align: center;">DNI</th>
						<th style="text-align: center;">ASISTENCIA</th>
						<th style="text-align: center;">OPCIONES</th>
					</tr>
				</thead>
				<tbody>
				<?php foreach ($asistencias as $a) { ?>
				<tr>
					<td><?php echo $a['Participante']['nombre']; ?></td>
					<td><?php echo $a['Participante']['apellido']; ?></td>
					<!--<td><?php echo $e['Evento']['estado']; ?></td>-->
					<td>
					<?php 
					if($a['Asistencia']['estado']==0)
					echo "Falto";
					else
					echo "Asistio";
					
					?>
					</td>
					<td><?php echo $a['Participante']['dni']; ?></td>
					<td>
					  <label>
					  	<?php if($a['Asistencia']['estado']==0) {?>
					    <input type="checkbox" name="data[Participante][]" value="<?php echo $a['Asistencia']['id']; ?>">				    
					  <?php }?>
					  </label>						
					</td>
					<td style="text-align: center" id="options">
							<div style="text-align:left;" id="edit" class="btn-group">
							  <button type="button" class="btn btn-success btn-xs">
							  	<span class="glyphicon glyphicon-edit"></span>
							  </button>
							  <button type="button" class="btn btn-success dropdown-toggle btn-xs" data-toggle="dropdown">
								<span class="caret"></span>
							  </button>
							  <ul class="dropdown-menu" role="menu">
							  	<li><a href="../Eventos/publicado?id=<?php echo $a['Evento']['id']; ?>">Publicar Evento</a></li>
							  	<li><a href="../Eventos/terminado?id=<?php echo $a['Evento']['id']; ?>">Terminar Evento</a></li>
							
							  </ul>

							</div>
						<a style="text-decoration:none;" href="../Eventos/detalle?id=<?php echo $a['Evento']['id']; ?>" title="Ver detalle" data-toggle="tooltip" data-placement="left" data-delay="300" >
							<button class="btn btn-info btn-xs" type="button">
								<span class="glyphicon glyphicon-list-alt"></span>
							</button>
						</a>
						
						<a style="text-decoration:none;" href="../Eventos/editar?id=<?php echo $a['Evento']['id']; ?>" title="Editar" data-toggle="tooltip" data-placement="bottom" data-delay="300" >
							<button class="btn btn-success btn-xs" type="button">
								<span class="glyphicon glyphicon-edit"></span>
							</button>
						</a>
						<a href="../Eventos/borrar?id=<?php echo $a['Evento']['id']; ?>" title="Borrar" data-toggle="tooltip" data-placement="right" data-delay="300" >
							<button type="button" class="btn btn-danger btn-xs">
								<span class="glyphicon glyphicon-trash"></span>
							</button>
						</a>
						<a href="../Eventos/exposicion?id=<?php echo $a['Evento']['id']; ?>" title="Agregar Exposicion" data-toggle="tooltip" data-placement="right" data-delay="300" >
							<button type="button" class="btn btn-warning btn-xs">
								<span class="glyphicon glyphicon-plus-sign"></span>
							</button>
						</a>
						<a style="text-decoration:none;" href="../Participantes/editar?id=<?php echo $a['Participante']['id']; ?>" title="Ver detale de Participante" data-toggle="tooltip" data-placement="bottom" data-delay="300" >
							<button class="btn btn-info btn-xs" type="button">
								<span class="glyphicon glyphicon-edit"></span>
							</button>
						</a>	
											
					</td>
				</tr>
				<?php } ?>
				</tbody>
			</table>
			
		</div>
	</div>
</div>
</form>
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="editModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
      		<form action="../Eventos/listar" method="post" class="form-horizontal" role="form">
	        	<div class="modal-header">
	          		<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
	          		<h4 class="modal-title" style="text-align:center;color:#194D89;">AGREGAR EVENTO</h4>
	        	</div>
	        	<div class="modal-body">
				  	<div class="form-group">
				    	<label style="text-align:right;padding-right:0;" for="input3" class="col-lg-2 control-label">Tema</label>
				    	<div class="col-lg-10">
				      		<input name="data[Evento][tema]" type="text" class="form-control" id="input3" placeholder="Tema">
				    	</div>
				  	</div>
			  		<div class="form-group" id="imagen">
						<div>
							<label style="text-align:right;padding-right:0;" for="upload" class="col-lg-2 control-label">Imagen</label>
							<button id="upload" type="button" class="col-lg-10 btn btn-success" style="padding:2px;font-size:12px;float:left;margin:2px 0 0 15px;width:78%">Subir Imagen</button>
						</div>
						<span id="status"></span>
						<div id="files"></div>
					</div>
				  	<div class="form-group">
				    	<label style="text-align:right;padding-right:0;" for="input4" class="col-lg-2 control-label">Descripción</label>
				    	<div class="col-lg-10">
				    		<textarea name="data[Evento][descripcion]" rows="3" class="form-control" id="input4" placeholder="Descripcion"></textarea>
				    		<input name="data[Evento][solicitantes_id]" type="hidden" class="form-control" id="input6" placeholder="Estado" value="<?php echo $id_solicitante;?>">
				    		<input name="data[Evento][estado]" type="hidden" class="form-control" id="input5" placeholder="Estado" value="1">
				    	</div>
				  	</div>
				</div>
	        	<div class="modal-footer">
	          		<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
	          		<input type="submit" class="btn btn-primary" value="Guardar"/>
	        	</div>
			</form>
		</div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<script>
	$('#options a').tooltip()
	// Upload Image
	$(function(){
		var btnUpload=$('#upload');
		var status=$('#status');
		new AjaxUpload(btnUpload, {
			action: '../files/upload-file.php',
			name: 'uploadfile',
			onSubmit: function(file, ext){
				 if (! (ext && /^(jpg|png|jpeg|gif)$/.test(ext))){ 
                    // extension is not allowed 
					status.text('Solo se permiten archivos JPG, PNG o GIF');
					return false;
				}
				status.text('Uploading...');
			},
			onComplete: function(file, response){
				//On completion clear the status
				status.text('');
				//Add uploaded file to list
				if(response==="success"){
					$('<div style="margin-top:30px;text-align:center;"></div>').appendTo('#files').html('<img width="100" height="100" src="../img/uploads/'+file+'"/><br />'+file+'<input style="height:0px" type="hidden" name="data[Evento][imagen]" value="../img/uploads/'+file+'"/>').addClass('uploadfile');
				} else{
					$('<li></li>').appendTo('#files').text(file).addClass('error');
				}
			}
		});
	});
	// Upload Image End
</script>